package com.open.capacity.controller;

import com.github.pagehelper.PageInfo;
import com.open.capacity.common.web.Result;
import com.open.capacity.model.BusinessFinance;
import com.open.capacity.model.PageModel;
import com.open.capacity.model.FinanceVO;
import com.open.capacity.service.BusinessFinanceService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

import java.util.List;

@RestController
@RequestMapping("/business/finance")
public class BusinessFinanceController {

    @Autowired
    private BusinessFinanceService businessFinanceService;

//    @PostMapping("/add")
//    public CommonResult<Object> add(BusinessFinance businessFinance) {
//        businessFinanceService.add(businessFinance);
//        return CommonResult.success(null);
//    }
//
//    @PostMapping("/delete")
//    public CommonResult<Object> delete(Long id) {
//        businessFinanceService.delete(id);
//        return CommonResult.success(null);
//    }
//
//    @PostMapping("/update")
//    public CommonResult<Object> update(BusinessFinance businessFinance) {
//        businessFinanceService.update(businessFinance);
//        return CommonResult.success(null);
//    }
//
//    @GetMapping("/findById")
//    public CommonResult<HashMap<String, List<BusinessFinance>>> findById(Long id) {
//        List<BusinessFinance> list = businessFinanceService.findById(id);
//        HashMap<String, List<BusinessFinance>> map = new HashMap<>();
//        map.put("data",list);
//        return CommonResult.success(map);
//    }

    /**
     * 返回商家财务列表
     * 固定当前商家ID-->商家财务数据
     * 模糊查询-->时间
     * 分页-->
     * @param pageModel
     * @return
     */
    @GetMapping("/findPage")
    public Result findPage(PageModel pageModel, BusinessFinance businessFinance) {
        PageInfo<BusinessFinance> list = businessFinanceService.findAll(pageModel,businessFinance);
        return Result.succeed(list,"商家个人财务数据显示成功！");
    }

    @GetMapping("/daily")
    public Result daily(Long busiid){
        List<FinanceVO> financeVo = businessFinanceService.daily(busiid);
        return Result.succeed(financeVo,"商家个人日总价报显示成功");
    }
    @GetMapping("/dailyList")
    public Result dailyList(PageModel pageModel,BusinessFinance businessFinance){
        PageInfo<BusinessFinance> vo = businessFinanceService.dailyList(pageModel,businessFinance);
        return Result.succeed(vo,"商家个人日数据报显示成功");
    }


    @GetMapping("/monthly")
    public Result monthly(Long busiid){
        List<FinanceVO> financeVo = businessFinanceService.monthly(busiid);
        return Result.succeed(financeVo,"商家个人月总价报显示成功");
    }
    @GetMapping("/monthlyList")
    public Result monthlyLIst(PageModel pageModel,BusinessFinance businessFinance){
        PageInfo<BusinessFinance> vo = businessFinanceService.monthlyList(pageModel,businessFinance);
        return Result.succeed(vo,"商家个人月报数据显示成功");
    }
}
